package com.tianji.aigc.controller;


import com.tianji.aigc.service.IChatSessionService;
import com.tianji.aigc.vo.ChatHistoryVO;
import com.tianji.aigc.vo.MessageVO;
import com.tianji.aigc.vo.SessionVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 对话session 前端控制器
 * </p>
 *
 * @author lty
 * @since 2025-09-02
 */
@RestController
@RequestMapping("/session")
public class ChatSessionController {
    /**
     * 新建对话
     */
    @Autowired
    private IChatSessionService chatSessionService;

    @PostMapping
    public SessionVO addChat(@RequestParam( value = "n",defaultValue = "3") Integer num){
        return chatSessionService.addChat(num);

    }
    /**
     * 创建会话
     * @param num
     * @return
     */
    @GetMapping("/hot")
    public List<SessionVO.Example> getHotSession(@RequestParam( value = "n",defaultValue = "3") Integer num){
        return chatSessionService.getHotSession(num);
    }
    /**
     * 查询对话列表
     * @param sessionId
     * @return
     */
    @GetMapping("/{sessionId}")
    public List<MessageVO> getList(@PathVariable String sessionId){
        return chatSessionService.getList(sessionId);
    }


    /**
     * 查询会话记忆历史
     */

    @GetMapping("/history")
    public Map<String,List<ChatHistoryVO>> getHistoryList(){
        return chatSessionService.getHistoryList();
    }



}
